﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    
                    xmlns:rub="clr-namespace:MiniUML.View.Views.RubberBand"
                    xmlns:views="clr-namespace:MiniUML.View.Views"
                    xmlns:selector="clr-namespace:MiniUML.View.TemplateSelector"
                    >
  <ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="/MiniUML.View;component/Themes/ResizeAdorner/DesignerItem.xaml" />
  </ResourceDictionary.MergedDictionaries>

  <!-- Style the rubber band selection on the canvas with a standard style -->
  <Style TargetType="{x:Type rub:RubberBandChrome}">
    <Style.Resources>
      <BooleanToVisibilityConverter x:Key="visConvi" />
    </Style.Resources>
    <Setter Property="Visibility" Value="{Binding DataContext.RubberBand.IsVisible, Converter={StaticResource visConvi}}"/>
    <Setter Property="Width" Value="{Binding Width}" />
    <Setter Property="Height" Value="{Binding Height}" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type rub:RubberBandChrome}">
          <Grid DataContext="{Binding DataContext.RubberBand}">

            <Border BorderBrush="#FF3399FF" BorderThickness="1"
                    HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
              <Border BorderBrush="#FFFFFFFF" BorderThickness="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                <Border Background="#20b8dafc" />
              </Border>
            </Border>

            <TextBlock Grid.Column="0" Grid.Row="0"  Foreground="Black"
                       HorizontalAlignment="Center" VerticalAlignment="Top"
                       Text="{Binding Width, Mode=OneWay, StringFormat={}{0:}}" />

                  <TextBlock Grid.Column="0" Grid.Row="1" Foreground="Black"
                             HorizontalAlignment="Left" VerticalAlignment="Center"
                             Text="{Binding Height, Mode=OneWay, StringFormat={}{0:}}">
                  <TextBlock.LayoutTransform>
                    <RotateTransform Angle="90" CenterX="1" CenterY="0.5"/>
                  </TextBlock.LayoutTransform>
                </TextBlock>
          </Grid>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style TargetType="{x:Type views:CanvasView}">
    <Setter Property="SnapsToDevicePixels" Value="True"/>
    <Setter Property="AllowDrop" Value="True" />
    <Setter Property="Focusable" Value="True" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type views:CanvasView}">
          <ItemsControl x:Name="Part_ItemsControl"
                        Focusable="False"
                        Background="White"
                        ItemsSource="{Binding Path=DocumentViewModel.dm_DocumentDataModel.DocRoot}"
                        AllowDrop="True">
            <ItemsControl.ContextMenu>
              <ContextMenu>
                <MenuItem Command="Cut">
                </MenuItem>
                <MenuItem Command="Copy">
                </MenuItem>
                <MenuItem Command="Paste">
                </MenuItem>
                <MenuItem Command="Delete">
                </MenuItem>
                <Separator />
                <MenuItem Command="Undo">
                </MenuItem>
                <MenuItem Command="Redo">
                </MenuItem>
              </ContextMenu>
            </ItemsControl.ContextMenu>
            <ItemsControl.ItemTemplateSelector>
              <selector:ShapeTemplateSelector/>
            </ItemsControl.ItemTemplateSelector>

            <ItemsControl.ItemsPanel>
              <ItemsPanelTemplate>
                <Canvas />
              </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>

            <ItemsControl.ItemContainerStyle>
              <Style TargetType="{x:Type FrameworkElement}">
                <!-- Style.Triggers>
                  <Trigger Property="Selector.IsSelected" Value="true">
                    <Setter Property="Effect">
                      <Setter.Value>
                        <DropShadowEffect BlurRadius="20" ShadowDepth="0" Color="Yellow" Opacity="1" />
                      </Setter.Value>
                    </Setter>
                  </Trigger>
                </Style.Triggers -->

                <!-- Initially position elements on canvas using these bindings -->
                <Setter Property="Canvas.Left" Value="{Binding Left}"/>
                <Setter Property="Canvas.Top" Value="{Binding Top}"/>
              </Style>
            </ItemsControl.ItemContainerStyle>

          </ItemsControl>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

</ResourceDictionary>